package com.cennavi.buss;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
@PropertySource(value = { "classpath:application.properties" })
public class WebMvcConfigurer extends WebMvcConfigurerAdapter {
	
	@Value("${spring.auth.expiry.file}")
	private String expiryFile;

	@Value("${spring.profiles.active}")
	private String profilesActive;

	public void addInterceptors(InterceptorRegistry registry) {
		if(!profilesActive.equals("dev")){
			registry.addInterceptor(new ExpirtyInterceptor(expiryFile)).addPathPatterns("/*").addPathPatterns("/**");
		}
	}
}